﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TiTi.tea.DAL;
using TiTi.tea.Model;

namespace TiTi.tea.BLL
{
    public class IntegralsInfoBLL
    {
        private IntegralsInfoDAL dal = new IntegralsInfoDAL();
        private UserInfoDAL userDal = new UserInfoDAL();
        private Configs configs = new ConfigsDAL().GetOne(o=>true);

        /// <summary>
        /// 根据消费金额添加积分记录
        /// </summary>
        /// <returns></returns>
        public void Add(int userId,decimal? money)
        {
            var entity = new IntegralsInfo()
            {
                AddType = 1,
                num = (int)(money/configs.IntegralsMoneyRate),
                CreateTime = DateTime.Now,
                UserId = userId,
            };
            
            dal.Add(entity,false);
        }

    }
}
